home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Pane2 / c / Show < prev   
Text File  |  1995-08-23  |  5KB  |  163 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Pane2.Show.c
  12.     Author:  Copyright © 1995 Andrew Sellors.
  13.     Version: 1.04 (4th August 1995)
  14.     Purpose: Handles windows with panes.
  15. */
  16.  
  17. #include "DeskLib:Pane2.h"
  18. #include "Pane2Defs.h"
  19. #include "Desklib:Event.h"
  20. #include "DeskLib:Template.h"
  21. #include "Desklib:EventMsg.h"
  22. #include "Desklib:Error.h"
  23.  
  24. #include <stdlib.h>
  25.  
  26.  
  27. /******************************************************************************/
  28.  
  29. extern void Pane2_Show(window_handle mainwindow, window_openpos openpos)
  30. {
  31.  /*
  32.   * Opens the main window 'mainwindow' and all it's attached pane windows
  33.   * according to 'openpos'
  34.   * Use in the same manner to Window_Show
  35.   */
  36.   main_listelement *mainelement;
  37.   pane_listelement *paneelement;
  38.   window_state panestate;
  39.   window_state mainstate;
  40.   window_handle lastbehind;
  41.  
  42.  /*
  43.   * find element for main window and return if mainwindow not present
  44.   */
  45.   mainelement = FindMainWindow(mainwindow);
  46.   if(mainelement == NULL)
  47.      return; /* not found */
  48.  
  49.  /*
  50.   * open main window
  51.   */
  52.   Window_Show(mainelement->mainwindow, openpos);
  53.   Wimp_GetWindowState(mainelement->mainwindow, &mainstate);
  54.  
  55.  /*
  56.   * level where first window should open behind
  57.   */
  58.   lastbehind = mainstate.openblock.behind;
  59.  
  60.  /*
  61.   * find first pane window
  62.   */
  63.   paneelement = LinkList_FirstItem(&(mainelement->paneanchor));
  64.   
  65.  /*
  66.   * open all pane windows
  67.   */ 
  68.   while(paneelement != NULL){
  69.  
  70.     /*
  71.      * get pane window info
  72.      */
  73.      Wimp_GetWindowState(paneelement->panewindow, &panestate);
  74.  
  75.     /*
  76.      * y position of pane
  77.      */
  78.      if(paneelement->paneflags.data.maintop) /* pane fixed to top of window */
  79.         panestate.openblock.screenrect.max.y = mainstate.openblock.screenrect.max.y -
  80.                                                paneelement->paneoffset.y;
  81.      else /* pane fixed to bottom of window */
  82.         panestate.openblock.screenrect.max.y = mainstate.openblock.screenrect.min.y -
  83.                                                paneelement->paneoffset.y;
  84.  
  85.      if(!paneelement->paneflags.data.panetop) /* pane fixed using bottom of pane */
  86.         panestate.openblock.screenrect.max.y += paneelement->panesize.y;
  87.  
  88.      if(paneelement->paneflags.data.vscroll) /* scroll pane vertical */
  89.         panestate.openblock.scroll.y = mainstate.openblock.scroll.y;
  90.  
  91.     /*
  92.      * y size of pane
  93.      */
  94.      if(paneelement->paneflags.data.vresize){ /* resize pane vertical */
  95.  
  96.         panestate.openblock.screenrect.min.y = mainstate.openblock.screenrect.min.y;
  97.  
  98.         if(!paneelement->paneflags.data.vstretch &&
  99.            (mainstate.openblock.screenrect.min.y < panestate.openblock.screenrect.max.y -
  100.                                                    paneelement->panesize.y))
  101.  
  102.            panestate.openblock.screenrect.min.y = panestate.openblock.screenrect.max.y -
  103.                                                   paneelement->panesize.y;
  104.      }
  105.      else
  106.         panestate.openblock.screenrect.min.y = panestate.openblock.screenrect.max.y -
  107.                                                paneelement->panesize.y;
  108.  
  109.     /*
  110.      * x position of pane
  111.      */
  112.      if(paneelement->paneflags.data.mainright)
  113.         panestate.openblock.screenrect.min.x = mainstate.openblock.screenrect.max.x +
  114.                                                paneelement->paneoffset.x;
  115.      else
  116.         panestate.openblock.screenrect.min.x = mainstate.openblock.screenrect.min.x +
  117.                                                paneelement->paneoffset.x;
  118.  
  119.      if(paneelement->paneflags.data.hscroll) /* scroll pane horizontal */
  120.         panestate.openblock.scroll.x = mainstate.openblock.scroll.x;
  121.  
  122.     /*
  123.      * x size of pane
  124.      */
  125.      if(paneelement->paneflags.data.hresize){ /* resize pane horizontal */
  126.  
  127.         panestate.openblock.screenrect.max.x = mainstate.openblock.screenrect.max.x;
  128.  
  129.         if(!paneelement->paneflags.data.hstretch &&
  130.            (mainstate.openblock.screenrect.max.x > panestate.openblock.screenrect.min.x +
  131.                                                    paneelement->panesize.x))
  132.  
  133.            panestate.openblock.screenrect.max.x = panestate.openblock.screenrect.min.x +
  134.                                                   paneelement->panesize.x;
  135.  
  136.      }
  137.      else
  138.         panestate.openblock.screenrect.max.x = panestate.openblock.screenrect.min.x +
  139.                                                paneelement->panesize.x;
  140.  
  141.  
  142.     /*
  143.      * open pane behind last pane or level where main window should have been
  144.      * if it is the first
  145.      */
  146.      panestate.openblock.behind = lastbehind;
  147.      Wimp_OpenWindow(&panestate.openblock);
  148.      lastbehind = paneelement->panewindow;
  149.      
  150.     /*
  151.      * find next pane window
  152.      */
  153.      paneelement = LinkList_NextItem(&(paneelement->header));
  154.   }
  155.  
  156.  /*
  157.   * open main window behind last pane
  158.   */
  159.   mainstate.openblock.behind = lastbehind;
  160.   Wimp_OpenWindow(&mainstate.openblock);
  161.  
  162. }
  163.